<template>
    <div>
        <el-table v-if="tableData3.length>0" :data="tableData3" border style="width: 100%" >
            <el-table-column prop="DOCTOR_ID" label="ID" width="180">
            </el-table-column>
            <el-table-column prop="DOCTOR_NAME" label="医生名称" width="180">
            </el-table-column>
            <el-table-column prop="DOCTOR_MAJOR" label="擅长专业" width="150">
            </el-table-column>
            <el-table-column prop="DOCTOR_TEL" label="电话" width="180">
            </el-table-column>
            <el-table-column prop="DOCTOR_ADDRESS" label="所属地区" width="200">
            </el-table-column>
            <el-table-column prop="DOCTOR_ADDRESSDETAIL" label="详细地址" width="200">
            </el-table-column>           
            <el-table-column label="操作" width="100" >
                <template scope="scope">
                    <el-button type="text" size="media" @click="goEditer(scope.row.DOCTOR_ID)" v-if="type!='学校查看'">
                        <i class="el-icon-view"> 查看</i>
                    </el-button>
                     <el-button type="text" size="media" v-else @click="goDelectDoctor(scope.row.DOCTOR_ID)">
                        <i class="el-icon-view"> 删除</i>
                    </el-button>
                </template>
            </el-table-column>
           
        </el-table>
        <div class="block">
            <el-pagination @current-change="handleCurrentChange" :current-page="currentPage1" :page-size="10" layout="total, prev, pager, next" :total="pagecount">
            </el-pagination>
        </div>
    </div>
</template>
<script>
import api from "@/js/api";
export default {
  data() {
    return {
      pagecount: 0,
      currentPage1: 1,
      tableData3: [],
      searchDate: {
        name: "",
        address: ""
      }
    };
  },
  props: {
    id: {
      type: {
        type: String,
        default: ""
      }
    },
    type: {
      type: String,
      default: "待沟通"
    }
  },
  methods: {
    goAddHostial(cid) {
      let data = {
        id: cid,
        type: "客户"
      };
      this.$emit("goAddHostial", data);
    },
    SelectMultipel(data) {
      // console.log(data);
      this.searchDate = data;
      let that = this;
      var sdata = {
        name: data.name == "" ? null : data.name,
        address: data.address == "" ? null : data.address,
        pageIndex: this.currentPage1,
        pageSize: 10
      };
      api.DOCTORSelectMultipel(that, sdata, function(msg) {
        that.tableData3 = msg.Result;
        that.pagecount = msg.ListCount;
      });
    },
    handleCurrentChange(val) {
      this.currentPage1 = val;
      this.SelectMultipel(this.searchDate);
    },
    goEditer(id) {
      this.$emit("goEditer", id);
    },
    getDate() {
      let that = this;
      api.DOCTORGetList(
        that,
        { pageIndex: this.currentPage1, pageSize: 10 },
        function(msg) {
          that.tableData3 = msg.Result;
          that.pagecount = msg.ListCount;
        }
      );
    },
    changeDate(data) {
      this.tableData3 = data;
      this.pagecount = data.length;
    },
    //删除
    goDelectDoctor(id){
      this.$emit("goDelectDoctor", id);
    }
  },
  created() {
    if (this.type != "学校查看") {
      this.getDate();
    }
  }
};
</script>
